const mongoose = require('mongoose');
const {model, Schema} = mongoose;

// 有效期
const expiresTime = 7 * 24 * 60 * 60 * 1000; // 7 天

// 登录令牌
const schema = new Schema({
  expiresTime: {type: Number, index: true, default: Date.now() + expiresTime}, // 有效的截止时间
  uId: {type: String, index: true, unique: true}, // 关联的用户id

  createTime: {type: Date, index: true, default: new Date()},
  updateTime: {type: Date, index: true, default: new Date()},
});

const Token = model('token', schema);

module.exports = {Token, expiresTime};
